﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using NS.Model.Systems;
using NS.BLL.Systems;
using NS.Utilities;

public partial class Systems_DeptModify : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            DataShow();
        }
    }
    private void DataShow()
    {
        Dept Model = DeptService.Select(Convert.ToInt64(Request.QueryString["ID"]));
        if (Model != null)
        {
            txtDeptName.Text = Model.DeptName;
            txtOrderID.Text = Model.OrderID.ToString();
        }
    }
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        Dept Model = DeptService.Select(Convert.ToInt64(Request.QueryString["ID"]));
        if (Model != null)
        {
            Model.DeptName = txtDeptName.Text.Trim();
            Model.OrderID = Convert.ToInt32(txtOrderID.Text.Trim());

            if (DeptService.Update(Model) > 0)
            {
               MessageBox.AppendScript(this, "$(':input[id$=\"btnBindData\"]', window.parent.document.body).click();");
            }
            else
            {
                MessageBox.ShowSaveError(this);
            }
        }
    }
}